import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Query } from '@nestjs/common';
import { ChannelService } from './channel.service';
import { CreateChannelDto } from './dto/create-channel.dto';
import { UpdateChannelDto } from './dto/update-channel.dto';
import { RequireLogin } from 'src/decorator/require-login.decorator';
import { LoginGuard } from 'src/login.guard';
import { RequirePermission } from 'src/decorator/require-permission.decorator';
import { PermissionGuard } from 'src/permission.guard';

@Controller('channel')
@RequireLogin()
@UseGuards(LoginGuard , PermissionGuard)
export class ChannelController {
  constructor(private readonly channelService: ChannelService) {}


    @Get()
    @RequirePermission('查询channel')
    findAll() {
        return this.channelService.findAll();
    }
    
    @Get('init')
    init(){
        return this.channelService.init()
    }

    @Get('/view')
    read(@Query() query: any){
        let {id} = query
        // return this.channelService.viewCountAdd(id)
        return this.channelService.viewByRedis(id)
    }


}
